# ARP related library files
add_library(ARP_FILES STATIC)
target_sources(ARP_FILES PUBLIC
        ${APP_DIR}/ARP/arp.c
)
target_include_directories(ARP_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/ARP
)
target_link_libraries(ARP_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)


# ping(ICMP) related library files
add_library(PING_FILES STATIC)
target_sources(PING_FILES PUBLIC
        ${APP_DIR}/PING/ping.c
)
target_include_directories(PING_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/PING
)
target_link_libraries(PING_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)

# NETBIOS related library files
add_library(NETBIOS_FILES STATIC)
target_sources(NETBIOS_FILES PUBLIC
        ${APP_DIR}/NETBIOS/netbios.c
)
target_include_directories(NETBIOS_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/NETBIOS
)
target_link_libraries(NETBIOS_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)


# HTTP Client related library files
add_library(HTTPC_FILES STATIC)
target_sources(HTTPC_FILES PUBLIC
        ${APP_DIR}/HTTPC/httpclient.c
)
target_include_directories(HTTPC_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/HTTPC
)
target_link_libraries(HTTPC_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)


# UpperComputer search related library files
add_library(UpperComputerSearch_FILES STATIC)
target_sources(UpperComputerSearch_FILES PUBLIC
        ${APP_DIR}/UpperComputerSearch/uppercomputersearch.c
)
target_include_directories(UpperComputerSearch_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/UpperComputerSearch
        ../port/
)
target_link_libraries(UpperComputerSearch_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
        IOLIBRARY_FILES
        hardware_spi
)


# WEBIO related library files
add_library(WEBIO_FILES STATIC)
target_sources(WEBIO_FILES PUBLIC
        ${APP_DIR}/WEBIO/userHandler.c
        ${APP_DIR}/WEBIO/userHandler.h
        ${APP_DIR}/WEBIO/webpage.h
        
)
target_include_directories(WEBIO_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/WEBIO
)
target_link_libraries(WEBIO_FILES PRIVATE
        ETHERNET_FILES
        HTTPS_FILES
        pico_stdlib
)


# SMTP related library files
add_library(SMTP_FILES STATIC)
target_sources(SMTP_FILES PUBLIC
        ${APP_DIR}/SMTP/smtp.c
        
)
target_include_directories(SMTP_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/SMTP
)
target_link_libraries(SMTP_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)

# CJSON related library files
add_library(CJSON_FILES STATIC)
target_sources(CJSON_FILES PUBLIC
        ${APP_DIR}/CJSON/cJSON.c
        
)
target_include_directories(CJSON_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/CJSON
)
target_link_libraries(CJSON_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)

# MODBUS_TCPS related library files
add_library(MODBUS_TCPS_FILES STATIC)
target_sources(MODBUS_TCPS_FILES PUBLIC
        ${APP_DIR}/MODBUS_TCP_SERVER/mb.c
        ${APP_DIR}/MODBUS_TCP_SERVER/mb.h
        ${APP_DIR}/MODBUS_TCP_SERVER/mbascii.c
        ${APP_DIR}/MODBUS_TCP_SERVER/mbascii.h
        ${APP_DIR}/MODBUS_TCP_SERVER/mbtcp.c
        ${APP_DIR}/MODBUS_TCP_SERVER/mbtcp.h
)
target_include_directories(MODBUS_TCPS_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/MODBUS_TCP_SERVER
)
target_link_libraries(MODBUS_TCPS_FILES PRIVATE
        ETHERNET_FILES
        W5100S_FILES
        pico_stdlib
)


# UPnP related library files
include_directories(
        ${WIZNET_DIR}/Application/loopback
        ${PORT_DIR}/
)

add_library(UPNP_FILES STATIC)

target_sources(UPNP_FILES PUBLIC
        ${APP_DIR}/UPnP/UPnP.c
        ${APP_DIR}/UPnP/MakeXML.c
        ${APP_DIR}/UPnP/hyperterminal.c
)
target_include_directories(UPNP_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/UPnP
)
target_link_libraries(UPNP_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib 
)

# WEBSOCKET related library files
add_library(WEBSOCKET_FILES STATIC)
target_sources(WEBSOCKET_FILES PUBLIC
        ${APP_DIR}/WEBSOCKET/base64.c
        ${APP_DIR}/WEBSOCKET/base64.h
        ${APP_DIR}/WEBSOCKET/sha1.c
        ${APP_DIR}/WEBSOCKET/sha1.h
        ${APP_DIR}/WEBSOCKET/websocket.c
        ${APP_DIR}/WEBSOCKET/websocket.h
)
target_include_directories(WEBSOCKET_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/WEBSOCKET
)
target_link_libraries(WEBSOCKET_FILES PRIVATE
        ETHERNET_FILES
        W5100S_FILES
        HTTPS_FILES
        pico_stdlib
)

# PPPOE related library files
add_library(PPPOE_FILES STATIC)
target_sources(PPPOE_FILES PUBLIC
        ${APP_DIR}/PPPOE/PPPoE.c
        ${APP_DIR}/PPPOE/PPPoE.h
        ${APP_DIR}/PPPOE/md5.c
        ${APP_DIR}/PPPOE/md5.h
)
target_include_directories(PPPOE_FILES INTERFACE
        ${APP_DIR}
        ${APP_DIR}/PPPOE
)
target_link_libraries(PPPOE_FILES PRIVATE
        ETHERNET_FILES
        W5100S_FILES
        pico_stdlib
)
